let fs = require('fs');
let user = {
    username: "admin1",
    password: "12345"
};

function reg() {
    let data = fs.readFileSync('./persons.json');
    let arr = JSON.parse(data.toString());
        let tag = false;
        for(let item of arr){
            if(item.username == user.username && item.password == user.password){
                tag = true;
                console.log('账户已存在');
            }
        };
        if(tag == false){
            arr.push(user);
            fs.writeFileSync('./persons.json',JSON.stringify(arr)); 
            console.log('注册成功');
        }
    };
    reg();
    